// 平方数之和
// https://leetcode.cn/problems/sum-of-square-numbers/
/**
 * @param {number} c
 * @return {boolean}
 */
var judgeSquareSum = function (c) {
    let left = 0;
    let right = Math.floor(Math.sqrt(c));
    while (left <= right) {
        const sum = left * left + right * right;
        if (sum === c) {
            console.log(`${c} yes:`, left, right);
            return true;
        } else if (sum < c) {
            left++;
        } else {
            right--;
        }
    }

    console.log(`${c} no`);
    return false;
};

judgeSquareSum(5);
judgeSquareSum(1);
judgeSquareSum(3);
